<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - include/caffe/util/math_functions.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">include/caffe/util</a> - math_functions.hpp<span style="font-size: 80%;"> (source / <a href="math_functions.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:25:26</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #ifndef CAFFE_UTIL_MATH_FUNCTIONS_H_</a>
<span class="lineNum">       2 </span>            : #define CAFFE_UTIL_MATH_FUNCTIONS_H_
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : #include &lt;stdint.h&gt;
<span class="lineNum">       5 </span>            : #include &lt;cmath&gt;  // for std::fabs and std::signbit
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #include &quot;glog/logging.h&quot;
<span class="lineNum">       8 </span>            : 
<span class="lineNum">       9 </span>            : #include &quot;caffe/common.hpp&quot;
<span class="lineNum">      10 </span>            : #include &quot;caffe/util/device_alternate.hpp&quot;
<span class="lineNum">      11 </span>            : #include &quot;caffe/util/mkl_alternate.hpp&quot;
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : namespace caffe {
<span class="lineNum">      14 </span>            : 
<span class="lineNum">      15 </span>            : // Caffe gemm provides a simpler interface to the gemm functions, with the
<span class="lineNum">      16 </span>            : // limitation that the data has to be contiguous in memory.
<span class="lineNum">      17 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      18 </span>            : void caffe_cpu_gemm(const CBLAS_TRANSPOSE TransA,
<span class="lineNum">      19 </span>            :     const CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
<span class="lineNum">      20 </span>            :     const Dtype alpha, const Dtype* A, const Dtype* B, const Dtype beta,
<span class="lineNum">      21 </span>            :     Dtype* C);
<span class="lineNum">      22 </span>            : 
<span class="lineNum">      23 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      24 </span>            : void caffe_cpu_gemv(const CBLAS_TRANSPOSE TransA, const int M, const int N,
<span class="lineNum">      25 </span>            :     const Dtype alpha, const Dtype* A, const Dtype* x, const Dtype beta,
<span class="lineNum">      26 </span>            :     Dtype* y);
<span class="lineNum">      27 </span>            : 
<span class="lineNum">      28 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      29 </span>            : void caffe_axpy(const int N, const Dtype alpha, const Dtype* X,
<span class="lineNum">      30 </span>            :     Dtype* Y);
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      33 </span>            : void caffe_cpu_axpby(const int N, const Dtype alpha, const Dtype* X,
<span class="lineNum">      34 </span>            :     const Dtype beta, Dtype* Y);
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      37 </span>            : void caffe_copy(const int N, const Dtype *X, Dtype *Y);
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      40 </span>            : void caffe_set(const int N, const Dtype alpha, Dtype *X);
<span class="lineNum">      41 </span>            : 
<span class="lineNum">      42 </span>            : inline void caffe_memset(const size_t N, const int alpha, void* X) {
<span class="lineNum">      43 </span>            :   memset(X, alpha, N);  // NOLINT(caffe/alt_fn)
<span class="lineNum">      44 </span>            : }
<span class="lineNum">      45 </span>            : 
<span class="lineNum">      46 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      47 </span>            : void caffe_add_scalar(const int N, const Dtype alpha, Dtype *X);
<span class="lineNum">      48 </span>            : 
<span class="lineNum">      49 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      50 </span>            : void caffe_scal(const int N, const Dtype alpha, Dtype *X);
<span class="lineNum">      51 </span>            : 
<span class="lineNum">      52 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      53 </span>            : void caffe_sqr(const int N, const Dtype* a, Dtype* y);
<span class="lineNum">      54 </span>            : 
<span class="lineNum">      55 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      56 </span>            : void caffe_sqrt(const int N, const Dtype* a, Dtype* y);
<span class="lineNum">      57 </span>            : 
<span class="lineNum">      58 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      59 </span>            : void caffe_add(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">      60 </span>            : 
<span class="lineNum">      61 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      62 </span>            : void caffe_sub(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">      63 </span>            : 
<span class="lineNum">      64 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      65 </span>            : void caffe_mul(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      68 </span>            : void caffe_div(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">      69 </span>            : 
<span class="lineNum">      70 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      71 </span>            : void caffe_powx(const int n, const Dtype* a, const Dtype b, Dtype* y);
<span class="lineNum">      72 </span>            : 
<span class="lineNum">      73 </span>            : unsigned int caffe_rng_rand();
<span class="lineNum">      74 </span>            : 
<span class="lineNum">      75 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      76 </span>            : Dtype caffe_nextafter(const Dtype b);
<span class="lineNum">      77 </span>            : 
<span class="lineNum">      78 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      79 </span>            : void caffe_rng_uniform(const int n, const Dtype a, const Dtype b, Dtype* r);
<span class="lineNum">      80 </span>            : 
<span class="lineNum">      81 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      82 </span>            : void caffe_rng_gaussian(const int n, const Dtype mu, const Dtype sigma,
<span class="lineNum">      83 </span>            :                         Dtype* r);
<span class="lineNum">      84 </span>            : 
<span class="lineNum">      85 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      86 </span>            : void caffe_rng_bernoulli(const int n, const Dtype p, int* r);
<span class="lineNum">      87 </span>            : 
<span class="lineNum">      88 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      89 </span>            : void caffe_rng_bernoulli(const int n, const Dtype p, unsigned int* r);
<span class="lineNum">      90 </span>            : 
<span class="lineNum">      91 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      92 </span>            : void caffe_exp(const int n, const Dtype* a, Dtype* y);
<span class="lineNum">      93 </span>            : 
<span class="lineNum">      94 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      95 </span>            : void caffe_log(const int n, const Dtype* a, Dtype* y);
<span class="lineNum">      96 </span>            : 
<span class="lineNum">      97 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      98 </span>            : void caffe_abs(const int n, const Dtype* a, Dtype* y);
<span class="lineNum">      99 </span>            : 
<span class="lineNum">     100 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     101 </span>            : Dtype caffe_cpu_dot(const int n, const Dtype* x, const Dtype* y);
<span class="lineNum">     102 </span>            : 
<span class="lineNum">     103 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     104 </span>            : Dtype caffe_cpu_strided_dot(const int n, const Dtype* x, const int incx,
<span class="lineNum">     105 </span>            :     const Dtype* y, const int incy);
<span class="lineNum">     106 </span>            : 
<span class="lineNum">     107 </span>            : // Returns the sum of the absolute values of the elements of vector x
<span class="lineNum">     108 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     109 </span>            : Dtype caffe_cpu_asum(const int n, const Dtype* x);
<span class="lineNum">     110 </span>            : 
<span class="lineNum">     111 </span>            : // the branchless, type-safe version from
<span class="lineNum">     112 </span>            : // http://stackoverflow.com/questions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c
<span class="lineNum">     113 </span>            : template&lt;typename Dtype&gt;
<span class="lineNum">     114 </span>            : inline int8_t caffe_sign(Dtype val) {
<span class="lineNum">     115 </span><span class="lineNoCov">          0 :   return (Dtype(0) &lt; val) - (val &lt; Dtype(0));</span>
<span class="lineNum">     116 </span>            : }
<span class="lineNum">     117 </span>            : 
<span class="lineNum">     118 </span>            : // The following two macros are modifications of DEFINE_VSL_UNARY_FUNC
<span class="lineNum">     119 </span>            : //   in include/caffe/util/mkl_alternate.hpp authored by @Rowland Depp.
<span class="lineNum">     120 </span>            : // Please refer to commit 7e8ef25c7 of the boost-eigen branch.
<span class="lineNum">     121 </span>            : // Git cherry picking that commit caused a conflict hard to resolve and
<span class="lineNum">     122 </span>            : //   copying that file in convenient for code reviewing.
<span class="lineNum">     123 </span>            : // So they have to be pasted here temporarily.
<span class="lineNum">     124 </span>            : #define DEFINE_CAFFE_CPU_UNARY_FUNC(name, operation) \
<span class="lineNum">     125 </span>            :   template&lt;typename Dtype&gt; \
<span class="lineNum">     126 </span>            :   void caffe_cpu_##name(const int n, const Dtype* x, Dtype* y) { \
<span class="lineNum">     127 </span>            :     CHECK_GT(n, 0); CHECK(x); CHECK(y); \
<span class="lineNum">     128 </span>            :     for (int i = 0; i &lt; n; ++i) { \
<span class="lineNum">     129 </span>            :       operation; \
<span class="lineNum">     130 </span>            :     } \
<span class="lineNum">     131 </span>            :   }
<a name="132"><span class="lineNum">     132 </span>            : </a>
<span class="lineNum">     133 </span>            : // output is 1 for the positives, 0 for zero, and -1 for the negatives
<span class="lineNum">     134 </span><span class="lineNoCov">          0 : DEFINE_CAFFE_CPU_UNARY_FUNC(sign, y[i] = caffe_sign&lt;Dtype&gt;(x[i]))</span>
<span class="lineNum">     135 </span>            : 
<span class="lineNum">     136 </span>            : // This returns a nonzero value if the input has its sign bit set.
<span class="lineNum">     137 </span>            : // The name sngbit is meant to avoid conflicts with std::signbit in the macro.
<span class="lineNum">     138 </span>            : // The extra parens are needed because CUDA &lt; 6.5 defines signbit as a macro,
<span class="lineNum">     139 </span>            : // and we don't want that to expand here when CUDA headers are also included.
<span class="lineNum">     140 </span>            : DEFINE_CAFFE_CPU_UNARY_FUNC(sgnbit, \
<span class="lineNum">     141 </span>            :     y[i] = static_cast&lt;bool&gt;((std::signbit)(x[i])))
<span class="lineNum">     142 </span>            : 
<span class="lineNum">     143 </span>            : DEFINE_CAFFE_CPU_UNARY_FUNC(fabs, y[i] = std::fabs(x[i]))
<span class="lineNum">     144 </span>            : 
<span class="lineNum">     145 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     146 </span>            : void caffe_cpu_scale(const int n, const Dtype alpha, const Dtype *x, Dtype* y);
<span class="lineNum">     147 </span>            : 
<span class="lineNum">     148 </span>            : #ifndef CPU_ONLY  // GPU
<span class="lineNum">     149 </span>            : 
<span class="lineNum">     150 </span>            : // Decaf gpu gemm provides an interface that is almost the same as the cpu
<span class="lineNum">     151 </span>            : // gemm function - following the c convention and calling the fortran-order
<span class="lineNum">     152 </span>            : // gpu code under the hood.
<span class="lineNum">     153 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     154 </span>            : void caffe_gpu_gemm(const CBLAS_TRANSPOSE TransA,
<span class="lineNum">     155 </span>            :     const CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
<span class="lineNum">     156 </span>            :     const Dtype alpha, const Dtype* A, const Dtype* B, const Dtype beta,
<span class="lineNum">     157 </span>            :     Dtype* C);
<span class="lineNum">     158 </span>            : 
<span class="lineNum">     159 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     160 </span>            : void caffe_gpu_gemv(const CBLAS_TRANSPOSE TransA, const int M, const int N,
<span class="lineNum">     161 </span>            :     const Dtype alpha, const Dtype* A, const Dtype* x, const Dtype beta,
<span class="lineNum">     162 </span>            :     Dtype* y);
<span class="lineNum">     163 </span>            : 
<span class="lineNum">     164 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     165 </span>            : void caffe_gpu_axpy(const int N, const Dtype alpha, const Dtype* X,
<span class="lineNum">     166 </span>            :     Dtype* Y);
<span class="lineNum">     167 </span>            : 
<span class="lineNum">     168 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     169 </span>            : void caffe_gpu_axpby(const int N, const Dtype alpha, const Dtype* X,
<span class="lineNum">     170 </span>            :     const Dtype beta, Dtype* Y);
<span class="lineNum">     171 </span>            : 
<span class="lineNum">     172 </span>            : void caffe_gpu_memcpy(const size_t N, const void *X, void *Y);
<span class="lineNum">     173 </span>            : 
<span class="lineNum">     174 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     175 </span>            : void caffe_gpu_set(const int N, const Dtype alpha, Dtype *X);
<span class="lineNum">     176 </span>            : 
<span class="lineNum">     177 </span>            : inline void caffe_gpu_memset(const size_t N, const int alpha, void* X) {
<span class="lineNum">     178 </span>            : #ifndef CPU_ONLY
<span class="lineNum">     179 </span>            :   CUDA_CHECK(cudaMemset(X, alpha, N));  // NOLINT(caffe/alt_fn)
<span class="lineNum">     180 </span>            : #else
<span class="lineNum">     181 </span>            :   NO_GPU;
<span class="lineNum">     182 </span>            : #endif
<span class="lineNum">     183 </span>            : }
<span class="lineNum">     184 </span>            : 
<span class="lineNum">     185 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     186 </span>            : void caffe_gpu_add_scalar(const int N, const Dtype alpha, Dtype *X);
<span class="lineNum">     187 </span>            : 
<span class="lineNum">     188 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     189 </span>            : void caffe_gpu_scal(const int N, const Dtype alpha, Dtype *X);
<span class="lineNum">     190 </span>            : 
<span class="lineNum">     191 </span>            : #ifndef CPU_ONLY
<span class="lineNum">     192 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     193 </span>            : void caffe_gpu_scal(const int N, const Dtype alpha, Dtype* X, cudaStream_t str);
<span class="lineNum">     194 </span>            : #endif
<span class="lineNum">     195 </span>            : 
<span class="lineNum">     196 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     197 </span>            : void caffe_gpu_add(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">     198 </span>            : 
<span class="lineNum">     199 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     200 </span>            : void caffe_gpu_sub(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">     201 </span>            : 
<span class="lineNum">     202 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     203 </span>            : void caffe_gpu_mul(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">     204 </span>            : 
<span class="lineNum">     205 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     206 </span>            : void caffe_gpu_div(const int N, const Dtype* a, const Dtype* b, Dtype* y);
<span class="lineNum">     207 </span>            : 
<span class="lineNum">     208 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     209 </span>            : void caffe_gpu_abs(const int n, const Dtype* a, Dtype* y);
<span class="lineNum">     210 </span>            : 
<span class="lineNum">     211 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     212 </span>            : void caffe_gpu_exp(const int n, const Dtype* a, Dtype* y);
<span class="lineNum">     213 </span>            : 
<span class="lineNum">     214 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     215 </span>            : void caffe_gpu_log(const int n, const Dtype* a, Dtype* y);
<span class="lineNum">     216 </span>            : 
<span class="lineNum">     217 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     218 </span>            : void caffe_gpu_powx(const int n, const Dtype* a, const Dtype b, Dtype* y);
<span class="lineNum">     219 </span>            : 
<span class="lineNum">     220 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     221 </span>            : void caffe_gpu_sqrt(const int n, const Dtype* a, Dtype* y);
<span class="lineNum">     222 </span>            : 
<span class="lineNum">     223 </span>            : // caffe_gpu_rng_uniform with two arguments generates integers in the range
<span class="lineNum">     224 </span>            : // [0, UINT_MAX].
<span class="lineNum">     225 </span>            : void caffe_gpu_rng_uniform(const int n, unsigned int* r);
<span class="lineNum">     226 </span>            : 
<span class="lineNum">     227 </span>            : // caffe_gpu_rng_uniform with four arguments generates floats in the range
<span class="lineNum">     228 </span>            : // (a, b] (strictly greater than a, less than or equal to b) due to the
<span class="lineNum">     229 </span>            : // specification of curandGenerateUniform.  With a = 0, b = 1, just calls
<span class="lineNum">     230 </span>            : // curandGenerateUniform; with other limits will shift and scale the outputs
<span class="lineNum">     231 </span>            : // appropriately after calling curandGenerateUniform.
<span class="lineNum">     232 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     233 </span>            : void caffe_gpu_rng_uniform(const int n, const Dtype a, const Dtype b, Dtype* r);
<span class="lineNum">     234 </span>            : 
<span class="lineNum">     235 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     236 </span>            : void caffe_gpu_rng_gaussian(const int n, const Dtype mu, const Dtype sigma,
<span class="lineNum">     237 </span>            :                             Dtype* r);
<span class="lineNum">     238 </span>            : 
<span class="lineNum">     239 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     240 </span>            : void caffe_gpu_rng_bernoulli(const int n, const Dtype p, int* r);
<span class="lineNum">     241 </span>            : 
<span class="lineNum">     242 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     243 </span>            : void caffe_gpu_dot(const int n, const Dtype* x, const Dtype* y, Dtype* out);
<span class="lineNum">     244 </span>            : 
<span class="lineNum">     245 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     246 </span>            : void caffe_gpu_asum(const int n, const Dtype* x, Dtype* y);
<span class="lineNum">     247 </span>            : 
<span class="lineNum">     248 </span>            : template&lt;typename Dtype&gt;
<span class="lineNum">     249 </span>            : void caffe_gpu_sign(const int n, const Dtype* x, Dtype* y);
<span class="lineNum">     250 </span>            : 
<span class="lineNum">     251 </span>            : template&lt;typename Dtype&gt;
<span class="lineNum">     252 </span>            : void caffe_gpu_sgnbit(const int n, const Dtype* x, Dtype* y);
<span class="lineNum">     253 </span>            : 
<span class="lineNum">     254 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     255 </span>            : void caffe_gpu_fabs(const int n, const Dtype* x, Dtype* y);
<span class="lineNum">     256 </span>            : 
<span class="lineNum">     257 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     258 </span>            : void caffe_gpu_scale(const int n, const Dtype alpha, const Dtype *x, Dtype* y);
<span class="lineNum">     259 </span>            : 
<span class="lineNum">     260 </span>            : #define DEFINE_AND_INSTANTIATE_GPU_UNARY_FUNC(name, operation) \
<span class="lineNum">     261 </span>            : template&lt;typename Dtype&gt; \
<span class="lineNum">     262 </span>            : __global__ void name##_kernel(const int n, const Dtype* x, Dtype* y) { \
<span class="lineNum">     263 </span>            :   CUDA_KERNEL_LOOP(index, n) { \
<span class="lineNum">     264 </span>            :     operation; \
<span class="lineNum">     265 </span>            :   } \
<span class="lineNum">     266 </span>            : } \
<span class="lineNum">     267 </span>            : template &lt;&gt; \
<span class="lineNum">     268 </span>            : void caffe_gpu_##name&lt;float&gt;(const int n, const float* x, float* y) { \
<span class="lineNum">     269 </span>            :   /* NOLINT_NEXT_LINE(whitespace/operators) */ \
<span class="lineNum">     270 </span>            :   name##_kernel&lt;float&gt;&lt;&lt;&lt;CAFFE_GET_BLOCKS(n), CAFFE_CUDA_NUM_THREADS&gt;&gt;&gt;( \
<span class="lineNum">     271 </span>            :       n, x, y); \
<span class="lineNum">     272 </span>            : } \
<span class="lineNum">     273 </span>            : template &lt;&gt; \
<span class="lineNum">     274 </span>            : void caffe_gpu_##name&lt;double&gt;(const int n, const double* x, double* y) { \
<span class="lineNum">     275 </span>            :   /* NOLINT_NEXT_LINE(whitespace/operators) */ \
<span class="lineNum">     276 </span>            :   name##_kernel&lt;double&gt;&lt;&lt;&lt;CAFFE_GET_BLOCKS(n), CAFFE_CUDA_NUM_THREADS&gt;&gt;&gt;( \
<span class="lineNum">     277 </span>            :       n, x, y); \
<span class="lineNum">     278 </span>            : }
<span class="lineNum">     279 </span>            : 
<span class="lineNum">     280 </span>            : #endif  // !CPU_ONLY
<span class="lineNum">     281 </span>            : 
<span class="lineNum">     282 </span>            : }  // namespace caffe
<span class="lineNum">     283 </span>            : 
<span class="lineNum">     284 </span>            : #endif  // CAFFE_UTIL_MATH_FUNCTIONS_H_
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
